<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <cc:interface>
        <cc:attribute name="title" default=""/>
        <cc:attribute name="subTitle" default =""/>
        <cc:attribute name="yLabel" default =""/>
        <cc:attribute name="xLabel" default=""/>
        <cc:attribute name="xMinTickInterval" default="0" />
    </cc:interface>

    <cc:implementation>
        <h:outputScript name="javascript/highcharts/js/highcharts.js" target="head" />
        <div id="#{cc.id}_chartDiv"/>

        <script type="text/javascript">               
            $(function() {
                // Data must be defined WITHIN the function. This prevents
                // different charts using the same data variables. 
                var options = {
                    credits: {
                        enabled: false
                    },
                    chart: {
                         renderTo: '#{cc.id}_chartDiv',
                         type: 'column',
                         zoomType: 'x',
                         //margin: [50, 50, 100, 80]
                     },
                     title: {
                         text: '#{cc.attrs.title}'
                     },
                     subtitle: {
                         text: '#{cc.attrs.subTitle}'
                     },
                     xAxis: {
                         title: {
                             enabled: true,
                             text: '#{cc.attrs.xLabel}'
                         }, 
                         minTickInterval: #{cc.attrs.xMinTickInterval}
                     },
                     yAxis: {
                         title: {
                             text: '#{cc.attrs.yLabel}'
                         }
                     },
                     legend: {
                         enabled: false
                     }
                };
                <cc:insertChildren />
                // Don't create the chart if there are no series defined.
                if(typeof options.series !== "undefined") {
                    if(options.series.length > 1) {
                        options.legend.enabled = true;
                    }
                    var chart = new Highcharts.Chart(options);
                }
            });
        </script>
    </cc:implementation>
</html>